package com.ylsk.check.task;

import com.ylsk.check.domain.ReportInfo;
import com.ylsk.check.domain.emum.ConstructionStatusEnum;
import com.ylsk.check.domain.vo.JeevesReportVO;
import com.ylsk.check.domain.vo.ReportInfoVO;
import com.ylsk.check.mapper.JeevesReportMapper;
import com.ylsk.check.mapper.ReportInfoMapper;
import com.ylsk.check.service.IJeevesReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 同步施工状态
 * 施工状态从非占道施工  变更为占道施工
 * 在填写占道上报的时候或者进场上报，会提前填写占道报备数据，此时工程状态为非占道施工
 * 到了占道报备的开始日期后，应该把状态从 非占道施工改为占道施工
 */
@Component("todayJeevesReportTask")
public class TodayJeevesReportTask {

    @Autowired
    private ReportInfoMapper reportInfoMapper;
    /**
     * 更新施工状态
     */
    public void updateConstructionStatus(){

        //  施工状态变更
        List<ReportInfoVO> reportInfoVOList = reportInfoMapper.selectChangeStatusData(null);
        if(!CollectionUtils.isEmpty(reportInfoVOList)){
            for (ReportInfoVO reportInfoVO : reportInfoVOList) {
                ReportInfo reportInfo = reportInfoMapper.selectById(reportInfoVO.getReportInfoId());
                reportInfo.setConstructionStatus(ConstructionStatusEnum.ROAD_CONSTRUCTION.getCode());
                reportInfoMapper.updateById(reportInfo);
            }
        }

    }
}
